<?php if($this->partners):?>
<h3>Your internship requests:</h3>
<table>
    <tr>
        <th>Name</th>
        <th>Phone</th>
        <th>Email</th>
        <th>Note</th>
    </tr>
    <?php foreach($this->partners as $p): ?>
	<tr id="row-<?php echo $p['ID']?>">
		<td><a href="<?php echo $this->url(array('controller'=>'common','action'=>'vieworganizationdetails','orgid'=>$p['ID']))?>"><?php echo $p['NAME']?></a></td>
		<td><?php echo $p['PHONE']?></td>
		<td>
			<?php if($p['EMAIL']):?>
				<a href="mailto:<?php echo $p['EMAIL']?>"><?php echo $p['EMAIL']?></a>
			<?php else:?>
				N/A
			<?php endif;?>
		</td>
		<td>
			<?php if($p['NOTE']):?>
				<a href="javascript:void(0)" onclick="showNote(<?php echo $p['ID']?>);">show</a>
			<?php else:?>
				None
			<?php endif;?>
		</td>
	</tr>
    <?php endforeach ?>
<?php endif; ?>
<?php if(!$this->partners):?>
	<tr>
		<td colspan="4"><h3>No partners found.</h3></td>
	</tr>
<?php endif; ?>
</table>

<script type="text/javascript">
	var notes = new Array();
	<?php foreach($this->partners as $p): ?>
		notes[<?php echo $p['ID']?>] = new Array();
		notes[<?php echo $p['ID']?>]['ID']='<?php echo $p['ID']?>';
		notes[<?php echo $p['ID']?>]['NAME']='<?php echo $p['NAME']?>';
		notes[<?php echo $p['ID']?>]['PHONE']='<?php echo $p['PHONE']?>';
		notes[<?php echo $p['ID']?>]['URL']='<?php echo $this->url(array('controller'=>'common','action'=>'vieworganizationdetails','orgid'=>$p['ID']))?>';
		<?php if($p['EMAIL']):?>
			notes[<?php echo $p['ID']?>]['EMAIL']='<?php echo $p['EMAIL']?>';
		<?php else:?>
		notes[<?php echo $p['ID']?>]['EMAIL']='N/A';
		<?php endif;?>
		notes[<?php echo $p['ID']?>]['NOTE']='<?php echo htmlentities(str_replace(array("\r\n", "\n", "\r"),'<br/>',$p['NOTE']), ENT_QUOTES)?>';
	<?php endforeach?>
	function hideNote(id){
		document.getElementById('row-'+id).innerHTML=
			"<td><a href="+notes[id]['URL']+">"+notes[id]['NAME']+"</a></td>"+
			"<td>"+notes[id]['PHONE']+"</td>"+
			"<td>"+notes[id]['EMAIL']+"</td>"+
			"<td><a href='javascript:void(0)' onclick='showNote("+notes[id]['ID']+");'>show</a></td>"
			;
	}
	function showNote(id){
		document.getElementById('row-'+id).innerHTML=
			"<td><a href="+notes[id]['URL']+">"+notes[id]['NAME']+"</a></td>"+
			"<td colspan = '3'>"+
			notes[id]['NOTE']+"<br/><a href='javascript:void(0)' onclick='hideNote("+notes[id]['ID']+");'>hide</a></td>";
	}
</script>
